import { createApp } from 'vue';
import App from './搜索.vue';
import 'vant/lib/index.css';

const app = createApp(App);
app.mount('#app');




// 初始化轮播图
const swiper = new Swiper('.swiper', {
    loop: true,
    autoplay: {
        delay: 3000,
        disableOnInteraction: false,
    },
    pagination: {
        el: '.swiper-pagination',
        clickable: true,
    },
});

// 导航项点击事件
document.querySelectorAll('.grid-item').forEach(item => {
    item.addEventListener('click', function() {
        const id = this.getAttribute('data-id');
        showToast(`点击了功能${id}`);
    });
});

// 内容项点击事件
document.querySelectorAll('.list-item').forEach(item => {
    item.addEventListener('click', function() {
        const id = this.getAttribute('data-id');
        showToast(`点击了内容${id}`);
    });
});

// 显示提示信息
function showToast(message) {
    // 创建toast元素
    const toast = document.createElement('div');
    toast.className = 'toast';
    toast.textContent = message;
    
    // 添加样式
    Object.assign(toast.style, {
        position: 'fixed',
        top: '50%',
        left: '50%',
        transform: 'translate(-50%, -50%)',
        backgroundColor: 'rgba(0, 0, 0, 0.7)',
        color: '#fff',
        padding: '10px 20px',
        borderRadius: '4px',
        zIndex: '9999',
        transition: 'opacity 0.3s'
    });

    // 添加到页面
    document.body.appendChild(toast);

    // 2秒后移除
    setTimeout(() => {
        toast.style.opacity = '0';
        setTimeout(() => {
            document.body.removeChild(toast);
        }, 300);
    }, 2000);
}

// 页面加载完成后的初始化
document.addEventListener('DOMContentLoaded', () => {
    // 可以在这里添加页面初始化逻辑
    console.log('页面加载完成');
}); 